//
//  LikeImageCollectionViewCell.m
//  NineGroupProject
//
//  Created by dllo on 15/12/23.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "LikeImageCollectionViewCell.h"
#import "UIImageView+WebCache.h"
#import "Masonry.h"

@implementation LikeImageCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
        self.dic = [NSMutableDictionary dictionary];
        [self creacteSubcell];
    }
    return self;
}

-(void)creacteSubcell{
    
    
    self.tiitleImage = [[UIImageView alloc]init];
    [self.contentView addSubview:self.tiitleImage];
    [self.tiitleImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.top.mas_equalTo(0);
        make.size.mas_equalTo(130 * WID);
    }];
    
    UIImageView *heartView = [[UIImageView alloc]init];
    heartView.image = [UIImage imageNamed:@"iconfont-heart.png"];
    [self.contentView addSubview:heartView];
    [heartView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(45 * WID);
        make.top.mas_equalTo(135 * HEI);
        make.size.mas_equalTo(20 * WID);
    }];
    
    self.likeLabel = [[UILabel alloc]init];
    self.likeLabel.textColor = [UIColor grayColor];
    self.likeLabel.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:self.likeLabel];
    [self.likeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(heartView.mas_right).offset(5 * WID);
        make.top.equalTo(heartView.mas_top);
        make.width.equalTo(heartView.mas_width).multipliedBy(2);
        make.height.equalTo(heartView.mas_height);
    }];
}


-(void)setDic:(NSMutableDictionary *)dic{
    
    _dic = dic;
    NSString *str = [NSString stringWithFormat:@"%@",[self.dic objectForKey:@"favNum"]];
    self.likeLabel.text = str;
    
    NSURL *url = [NSURL URLWithString:[self.dic objectForKey:@"image"]];
    [self.tiitleImage sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"placeholderImag.png"]];
}


@end
